package cn.znk.kedis.master_slave_model.autoconfigure;

import cn.znk.kedis.master_slave_model.aspect.KedisDynamicAspect;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * IntelliJ IDEA
 * project: kedis-spring-boot-starter
 *
 * @author shimi
 * @since 2021/11/22
 * @version 1.0.2
 */
@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass({RedisMasterAutoConfiguration.class, RedisSlaveAutoConfiguration.class})
public class KedisDynamicAutoConfiguration {

    @Bean
    @ConditionalOnProperty(
            prefix = RedisConfigureConstants.GLOBAL_CONFIGURE_PREFIX,
            value = "enable-dynamic",
            havingValue = "true"
    )
    public KedisDynamicAspect kedisDynamicAspect() {
        return new KedisDynamicAspect();
    }

}
